package LeetCode.leetcode53;

import java.util.HashMap;

class Solution {
    public int maxSubArray(int[] nums) {
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        int sum = 0;
        for(int index: nums){
            sum += index;
            min = Math.min(min, sum);
            max = Math.max(max, sum - min);
        }
        return max;
        
    }
}